/**
 *
 * @author cheng sir
 * 2016年9月3日下午4:23:58
 */
package com.angel.provider.health.impl;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.angel.core.base.BaseProviderImpl;
import com.angel.dao.health.BuzReserveAdditionalMapper;
import com.angel.dao.health.BuzReserveMapper;
import com.angel.health.BuzReserve;
import com.angel.health.BuzReserveAdditional;
import com.angel.provider.health.BuzReserveProvider;

/**
 * @author cheng sir
 * 2016年9月3日下午4:23:58
 */
@Service
public class BuzReserveProviderImpl extends BaseProviderImpl<BuzReserve> implements BuzReserveProvider {
	
	@Autowired
	private BuzReserveMapper buzReserveMapper;
	@Autowired
	private BuzReserveAdditionalMapper buzReserveAdditionalMapper;

	public int save(BuzReserve buzReserve) {
		Date date = new Date();
		buzReserve.setCreateTime(date);
		buzReserve.setUpdateTime(date);
		int insert = buzReserveMapper.insert(buzReserve);
		if(insert > 0){
			List<BuzReserveAdditional> braList = buzReserve.getReserveAdditionalList();
			for(BuzReserveAdditional buzReserveAdditional : braList){
				buzReserveAdditional.setReserveId(buzReserve.getId());
			}
			buzReserveAdditionalMapper.insertList(braList);
		}
		return insert;
	}


	public List<Map<String,Object>> findReserveAll(BuzReserve buzReserve) {
		List<Map<String,Object>> findReserveAll = buzReserveMapper.findReserveAll(buzReserve);
		return findReserveAll;
	}


	@Override
	public BuzReserve getById(Integer id) {
		// TODO Auto-generated method stub
		return buzReserveMapper.selectByPrimaryKey(id);
	}

	@Override
	public BuzReserve lookById(Integer id) {
		// TODO Auto-generated method stub
		return buzReserveMapper.lookById(id);
	}
}
